﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using WeifenLuo.WinFormsUI.Docking;
using BADDGUI.Controls;
using System.Drawing;

namespace BADDGUI
{
    public partial class BLCForm : DockContent,IBaseForm
    {
        #region Constructor & Load

        public BLCForm()
        {
            InitializeBaseData();
        }

        public BLCForm(IContainer container)
        {
            container.Add(this);
            InitializeBaseData();
        } 

        #endregion

        #region Event

        private void BLCForm_Leave(object sender, EventArgs e)
        {
            BLCGlobalObject.ActiveForm = null;
        }

        private void BLCForm_Enter(object sender, EventArgs e)
        {
            BLCGlobalObject.ActiveForm = this;
        } 

        #endregion

        #region Method

        public void InitializeBaseData()
        {
            if (LicenseManager.UsageMode != LicenseUsageMode.Runtime) return;

            this.Enter += new EventHandler(BLCForm_Enter);
            this.Leave += new EventHandler(BLCForm_Leave);

            object frmKey = BLCGlobalObject.FrmModuleList.SelectedNode["View Frm Key"];
            object frmText = BLCGlobalObject.FrmModuleList.SelectedNode["View Frm Name"];
            object viewName = BLCGlobalObject.FrmModuleList.SelectedNode["View Name"];

            this.controlName = frmKey == null || Convert.IsDBNull(frmKey) ?
                                string.Empty : (string)frmKey;

            this.controlText = frmText == null || Convert.IsDBNull(frmText) ?
                                string.Empty : (string)frmText;

            this.formView = viewName == null || Convert.IsDBNull(viewName) ?
                                string.Empty : (string)viewName;

            this.Name = controlName;
            this.Text = controlText;
        } 

        #endregion

        #region Property

        private string controlName = "";
        public string ControlName
        {
            get { return controlName; }
        }

        private string controlText = "";
        public string ControlText
        {
            get { return controlText; }
        }

        private string formView = "";
        public string FormView
        {
            get { return formView; }
        }

        private BLCDataGridView dataGrid;
        public BLCDataGridView DataGrid
        {
            get { return dataGrid; }
            set { dataGrid = value; }
        }

        private BLCViewToolStrip viewFilter;
        public BLCViewToolStrip ViewFilter
        {
            get { return viewFilter; }
            set { viewFilter = value; }
        } 

        #endregion
    }
}